package zouran.controller;


import org.springframework.web.bind.annotation.*;
import zouran.entity.sauver.Fource;
import zouran.entity.sauver.Goods;
import zouran.result.ResultMap;
import zouran.service.SauverService;

import java.util.Map;

@RestController
@RequestMapping("/sauver")
public class SauverController {

    private final SauverService sauverService;

    private final ResultMap<Fource> resultMap1;

    private final ResultMap<Goods> resultMap2;


    public SauverController(SauverService sauverService,ResultMap<Fource> resultMap1,ResultMap<Goods> resultMap2){
        this.sauverService = sauverService;
        this.resultMap1 = resultMap1;
        this.resultMap2 = resultMap2;
    }


    @GetMapping("/getallForce")
    public ResultMap getallForce(){
        return resultMap1.success(sauverService.getAllForce());
    }


    @PostMapping("/getforceBylimit")
    public ResultMap getForceBylimit(@RequestBody Map<String, String> params){
            return resultMap1.success(sauverService.getForceBylimit(params));}

    @PostMapping("/getNearEarthquakeBydis")
    public ResultMap getNearearthquakeBydisscope(@RequestBody Map<String,Double> centerPointscope){
        System.out.println(centerPointscope);
        return resultMap1.success(sauverService.getearthquakeScopeforce(centerPointscope));

    }

    @GetMapping("/getallgoods")
    public ResultMap getallgoods(){
        return resultMap2.success(sauverService.getAllGoods());
    }

    @GetMapping("/getpointgoodsByid")
    public ResultMap getPointgoods(@RequestParam int id){
        return resultMap2.success(sauverService.getPointgoodsBy(id));
    }



}
